Repository navigation
feat(codegen-ts): sync SQLite service transactions and D1 service option - #643
Merged
Merged
Conversation
…oint, and its cost
… interactiveTransactions: false for D1
The generated service committed at its first await on a sync SQLite driver (bun:sqlite,
better-sqlite3), so a refusal answered 409 over a row that stayed. The runtime now drives
those drivers' transaction with BEGIN IMMEDIATE/COMMIT/ROLLBACK, serialized per handle, and
the sqlite Db type accepts a sync driver again. serviceFile({ interactiveTransactions: false })
generates a service with no transaction, hooks or event hook for D1, and refuses a declared
command with ERR_STORE_NO_INTERACTIVE_TX. ADR-0067 section 4 says so.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
BEGIN IMMEDIATE,COMMITandROLLBACK, instead of Drizzle'stransaction(), which committed at the firstawait. Transactions serialize per database handle. A caller-supplied transaction gets a savepoint, and a read outside a transaction waits for the one in flight. New exportwithWriteTransaction(db, fn)runs several operations atomically on any driver. The generated SQLiteDbtype accepts sync and async drivers again; theasyncOnlyoption ofdbTypeBlockis removed.serviceFile({ interactiveTransactions: false })option, also on the ejectable reference twin and in the generator registry, for stores that hold no transaction across application code (Cloudflare D1). The service opens no transaction, and it generates noHooks/Eventsinterfaces ordepsslots. A package that declares a command fails generation withERR_STORE_NO_INTERACTIVE_TX, naming the package, the command and the option. Queries still generate.@inputRefvalidation before the permission point, and states the cost: a caller the policy would refuse can see a 400 before a 403. ADR-0067 §4 describes the new option and the refusal.docs/features/business-rules.md,docs/ports/typescript.mdand the CHANGELOG cover the sync SQLite behavior and thewithWriteTransactioncaveat: on a sync driver, an operation that is not passed the outertxwaits on the transaction it is inside and never runs.Validation
Risk Assessment
✅ Low: The change meets every stated criterion: both ADR amendments, the sync-SQLite fix with a widened Db type, the no-transaction option with its refusal, and tests that exercise real drivers. No concrete failing sequence turned up, and the known deadlock on a sync driver is documented.
Testing
Minimal retry; see full result.
Gate and scope
serviceentry inmeta gen --listdid not list the newinteractiveTransactions?option.Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
scripts/ci-local.sh --affected --strict-toolchainsbun test packages/runtime-ts/test/service-sync-sqlite.test.tsbun test packages/integration-tests/test/service-sqlite-drivers.test.tsbun test packages/codegen-ts/test/service-file.test.ts🔧 **Document** - 1 issue found → auto-fixed ✅
server/typescript/packages/codegen-ts/src/generator-registry.ts:305- Generator catalog options string forserviceomits the newinteractiveTransactions?option.generator-registry.tsline 305 still readsoptions: "filter?, runtimeImport?, target?". It should listinteractiveTransactions?. This is a code string shown bymeta gen --list, not a doc, so the doc-only rule kept it out of this phase.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.